<template>
  <div class="w">
    <div class="header">
      <i class="iconfont icon-fanhui" @click="back"></i>
      <span class="title">我的收藏</span>
    </div>
    <div class="info">
      <div class="info_card" v-for="(item, index) in collectList" :key="index">
        <div class="card_top">
          <div class="top_left">
            <el-image :src="item.shopDto.shopImage" fit="cover"></el-image>
          </div>
          <div class="top_right">
            <div class="right_title">
              {{ item.shopDto.shopName }}
            </div>
            <div class="right_sales">月销{{ item.shopDto.sales }}</div>
            <div class="right_discounts">
              <div class="discounts_left">
                <span>{{ item.shopDto.discounts }}</span>
              </div>
              <div class="discounts_right">
                <span v-if="item.shopDto.mode == 0">商家自配</span>
                <span v-if="item.shopDto.mode == 1">骑手专送</span>
              </div>
            </div>
          </div>
        </div>
        <div class="card_bottom">
          <div class="card_dish" v-for="(it, ind) in item.shopDto.dishList" :key="ind">
            <div class="dish_img">
              <el-image :src="it.dishImage" fit="cover"></el-image>
            </div>
            <div class="dish_name">{{ it.dishName }}</div>
            <div class="dish_price">￥{{ it.dishPrice }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      info: [],
      collectList: [],
    };
  },

  created() {
    this.info = JSON.parse(localStorage.getItem('userInfo'));
    this.getCollectList();
  },

  methods: {
    back() {
      this.$router.push('/my');
    },
    async getCollectList() {
      const { data: res } = await this.$http.get('collect/getCollect/' + this.info.id);
      if (res.code == 1) {
        this.collectList = res.data;
        console.log(this.collectList);
      } else {
        return this.$message.error('收藏列表获取失败');
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.w {
  height: 100vh;
  width: 100%;
  .header {
    background-color: #fff;
    height: 70px;
    color: #0a0a0a;
    text-align: center;
    position: relative;
    margin-bottom: 20px;
    .icon-fanhui {
      position: absolute;
      font-size: 25px;
      line-height: 70px;
      left: 10px;
    }
    .title {
      font-size: 20px;
      line-height: 70px;
    }
  }
  .info::-webkit-scrollbar {
    display: none;
  }
  .info {
    padding: 10px;
    overflow: auto;
    height: calc(100vh - 110px);
    scrollbar-width: none;
    -ms-overflow-style: none;
    background-color: #f3f2f4;
    .info_card {
      background-color: #fefefe;
      border-radius: 10px;
      padding: 10px;
      margin-bottom: 10px;
      .card_top {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
        .top_left {
          margin-right: 10px;
          :deep(.el-image) {
            height: 65px;
            width: 65px;
            border-radius: 10px;
          }
        }
        .top_right {
          .right_title {
            font-size: 20px;
            font-weight: bold;
            color: #000000;
          }
          .right_sales {
            color: #898a8b;
            font-size: 13px;
            margin-bottom: 5px;
          }
          .right_discounts {
            width: 265px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            .discounts_left {
              border-radius: 5px;
              padding: 2px 4px;
              border: 1px solid #f9dfdc;
              color: #ec684a;
              font-size: 13px;
            }
            .discounts_right {
              padding: 2px 4px;
              background-color: #f8dfb4;
              border-radius: 5px;
              font-size: 13px;
              color: #60472d;
            }
          }
        }
      }
      .card_bottom::-webkit-scrollbar {
        display: none;
      }
      .card_bottom {
        display: flex;
        width: 100%;
        overflow: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        .card_dish {
          margin-right: 5px;
          .dish_img {
            margin-bottom: 10px;
            :deep(.el-image) {
              height: 110px;
              width: 150px;
              border-radius: 10px;
            }
          }
          .dish_name {
            font-size: 16px;
            font-weight: bold;
            color: #000000;
            -webkit-line-clamp: 1;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            overflow: hidden;
            text-overflow: ellipsis;
          }
          .dish_price {
            font-size: 16px;
            color: #eb5b3b;
          }
        }
      }
    }
  }
}
</style>